package com.example.oasysflow.service.flowservice;

import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.*;
import org.flowable.idm.api.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: FlowServiceImpl
 * @Description:
 * @author: WangZe
 * @date: 2022/4/4 11:56
 */
@Service
@Slf4j
public class FlowServiceImpl implements FlowService {
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private TaskService taskService;
    @Autowired
    private RepositoryService repositoryService;
    @Autowired
    private ProcessEngine processEngine;
    @Autowired
    private HistoryService historyService;
    @Autowired
    private IdentityService identityService;

    @Override
    public User getUser(String userId) {
        return identityService.createUserQuery().userId(userId).singleResult();
    }

    @Override
    public User addUser(String userId) {
        User user = identityService.newUser(userId);
        user.setFirstName(userId);
        user.setLastName(userId);
        user.setEmail(userId+ "@qq.com");
        identityService.saveUser(user);
        return user;
    }
}
